MESSAGE(STATUS "Enter: " ${CMAKE_CURRENT_SOURCE_DIR})

INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/public")
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/inc")

if (CONFIG_COMMON_CRC)
    AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/Crc CRC)
endif (CONFIG_COMMON_CRC)

if (CONFIG_COMMON_SOCKET)
    AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/Socket SOCKET)
endif (CONFIG_COMMON_SOCKET)

if (CONFIG_COMMON_LINUX_SHM) 
    AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/LinuxShm LINUX_SHM)
endif (CONFIG_COMMON_LINUX_SHM)

if (CONFIG_COMMON_LINUX_MSG)
    AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/LinuxMsg LINUX_MSG)
endif (CONFIG_COMMON_LINUX_MSG)

if (CONFIG_COMMON_LINUX_SEM) 
    AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/LinuxSem LINUX_SEM)
endif (CONFIG_COMMON_LINUX_SEM)

if (CONFIG_COMMON_UART)
    AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/Uart UART)
endif (CONFIG_COMMON_UART)

if (CONFIG_COMMON_MXML)
    INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/thrid_party/mxml")
    AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/Xml MXML)
endif (CONFIG_COMMON_MXML)

if (CONFIG_COMMON_I2C)
    AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/i2c I2C)
endif (CONFIG_COMMON_I2C)

if (CONFIG_COMMON_TIMER) 
    AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/Timer TIMER)
endif (CONFIG_COMMON_TIMER)

if (CONFIG_COMMON_LOGGER)
    AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/Logger LOGGER)
endif (CONFIG_COMMON_LOGGER)

if (CONFIG_COMMON_CYCLE_QUEUE)
    AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/CycleQueue CYCLE_QUEUE)
endif (CONFIG_COMMON_CYCLE_QUEUE)

if (CONFIG_COMMON_THREAD_POOL)
    AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src/ThreadPool THREAD_POOL)
endif (CONFIG_COMMON_THREAD_POOL)

#FILE(GLOB_RECURSE SRC_LISTS ${CMAKE_CURRENT_SOURCE_DIR}/*.c)

SET(SRC_LISTS ${CRC} ${SOCKET} ${LINUX_SHM} ${LINUX_MSG} ${LINUX_SEM} ${UART} ${I2C} 
              ${TIMER} ${LOGGER} ${CYCLE_QUEUE} ${THREAD_POOL})

ADD_LIBRARY(common SHARED ${SRC_LISTS})
